package org.example.exceptioncatch.demos.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.*;

@Configuration
public class ThreadPoolConfig {

    @Bean  //创建一个线程池
    public ThreadPoolExecutor myThreadPool() {

        ThreadPoolExecutor executor = new ThreadPoolExecutor(2, 5,
                1L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(3),
                Executors.defaultThreadFactory(), new ThreadPoolExecutor.CallerRunsPolicy());

        return executor;

    }


}
